import com.google.code.bing.search.client.BingSearchClient;
import com.google.code.bing.search.client.BingSearchClient.SearchRequestBuilder;
import com.google.code.bing.search.client.BingSearchServiceClientFactory;
import com.google.code.bing.search.schema.AdultOption;
import com.google.code.bing.search.schema.SearchOption;
import com.google.code.bing.search.schema.SearchResponse;
import com.google.code.bing.search.schema.SourceType;
import com.google.code.bing.search.schema.web.WebResult;
import com.google.code.bing.search.schema.web.WebSearchOption;


public class TestBing {



	public static void main(String[] args) {
		BingSearchServiceClientFactory factory = BingSearchServiceClientFactory.newInstance();
		BingSearchClient client = factory.createBingSearchClient();
		
		SearchRequestBuilder builder = client.newSearchRequestBuilder();
		builder.withAppId("B47E474EC2280B209E026F084E6D8F3E520968FC");
		builder.withQuery("msdn blogs");
		builder.withSourceType(SourceType.WEB);
		builder.withVersion("2.0");
		builder.withMarket("en-us");
		builder.withAdultOption(AdultOption.OFF);
		builder.withSearchOption(SearchOption.DISABLE_LOCATION_DETECTION);

		builder.withWebRequestCount(50L);
		builder.withWebRequestOffset(0L);
		builder.withWebRequestSearchOption(WebSearchOption.DISABLE_HOST_COLLAPSING);
		builder.withWebRequestSearchOption(WebSearchOption.DISABLE_QUERY_ALTERATIONS);

		SearchResponse response = client.search(builder.getResult());

		int i = 0;
		
		for (WebResult result : response.getWeb().getResults()) {
		        System.out.println(i++);
				System.out.println(result.getTitle());
		        System.out.println(result.getDescription());
		        System.out.println(result.getUrl());
		        System.out.println(result.getDateTime());
		}
	}
	
}
